package com.example.demo;

import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author YuanYuan
 * @Date 2023/2/11
 * @Time 11:43
 */
//当前类为控制器
@Controller
//返回的是数据,而非页面
@ResponseBody
public class TestController {
    //等同于Servlet,url路由注册,完成映射
    @RequestMapping("/hi")
    public String sayHi(String name) {
        //为空为null,默认值处理
        if(!StringUtils.hasLength(name)) {
            name = "哒哒";
        }
        return "hi! " + name;

    }
}
